// pages/promotion/stat/stat.js
var util = require('../../../utils/util.js');
var doctorservice = require("../../../apiservice/doctor/doctorservice");
import Toast from "../../../lib/vant/toast/toast"
const app = getApp();
const regeneratorRuntime = app.globalData.regeneratorRuntime;
Page({

  /**
   * 页面的初始数据
   */
  data: {
	statistics:{},
	startDate: util.formatTime(new Date()),
	endDate: util.formatTime(new Date()),
  },

  /**
   * 生命周期函数--监听页面加载
   */
   onLoad: async function (options) {
     var currentDate = util.getMonthDate();
    console.log(currentDate.starttime);
    console.log(currentDate.endtime);
    var currStatistics = await doctorservice.QryNetDoctorsStatistic(currentDate.starttime, currentDate.endtime);
    this.setData({
      statistics: currStatistics.data,
      startDate: currentDate.starttime,
      endDate: currentDate.endtime
    });

  },

  getStatistics: async function(e){
    console.log(e);
    if(e.detail.endtime<e.detail.starttime){
      Toast("结束日期必须大于开始日期!");
      return;
    }
    var currStatistics = await doctorservice.QryNetDoctorsStatistic(e.detail.starttime,e.detail.endtime);
	  this.setData({
		  statistics:currStatistics.data,
      startDate: e.detail.starttime,
      endDate: e.detail.endtime
	  });
    
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})